import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 用户协议信息 */
export interface UserAgreement {
  id: number // id
  content?: string // 内容
  updateTime?: Dayjs | string // 更新者
}

// 用户协议 API
export const UserAgreementApi = {
  // 查询用户协议分页
  getUserAgreementPage: async (params: any) => {
    return await request.get({ url: `/biz/user-agreement/page`, params })
  },

  // 查询用户协议详情
  getUserAgreement: async (id: number) => {
    return await request.get({ url: `/biz/user-agreement/get?id=` + id })
  },

  // 新增用户协议
  createUserAgreement: async (data: UserAgreement) => {
    return await request.post({ url: `/biz/user-agreement/create`, data })
  },

  // 修改用户协议
  updateUserAgreement: async (data: UserAgreement) => {
    return await request.put({ url: `/biz/user-agreement/update`, data })
  },

  // 删除用户协议
  deleteUserAgreement: async (id: number) => {
    return await request.delete({ url: `/biz/user-agreement/delete?id=` + id })
  },

  /** 批量删除用户协议 */
  deleteUserAgreementList: async (ids: number[]) => {
    return await request.delete({ url: `/biz/user-agreement/delete-list?ids=${ids.join(',')}` })
  },

  // 导出用户协议 Excel
  exportUserAgreement: async (params) => {
    return await request.download({ url: `/biz/user-agreement/export-excel`, params })
  }
}
